#!/system/bin/sh

BASEDIR="$(dirname $(readlink -f "$0"))"

function boot(){
while true;
do
btcplt=$(getprop vendor.oplus.boot_complete)
if [ "$btcplt" -eq "1" ];then
	return 0
fi
sleep 1
done
}
boot
sleep 3
chown root:root /sys/class/oplus_chg/battery/bcc_current
chown root:root /sys/class/oplus_chg/battery/cool_down
chown root:root /sys/class/oplus_chg/battery/normal_cool_down
chown root:root /sys/class/oplus_chg/battery/normal_current_now

max_ma_rounded=9100

echo "最大电流约为: $max_ma_rounded ma"

#echo "最大电流约为: $max_ma_rounded ma"


#守护进程，进程处于持续睡眠阶段，耗电量几乎为零
result=1
while true;
do
	#ps -Aef | grep vendor.oplus.hardware.charger-Gs-service | grep -v grep
	pkill -f vendor.oplus.hardware.charger-Gs-service
    $BASEDIR/bin/vendor.oplus.hardware.charger-Gs-service $max_ma_rounded >/dev/null 2>&1
    # 阻塞进程，当进程被杀死后再继续执行
done